package com.example.shiwuyouproject.ui.fragment.home.viewmodel
import androidx.lifecycle.MutableLiveData
import com.example.shiwuyouproject.base.BaseViewModel
import com.example.shiwuyouproject.ui.fragment.home.bean.GetSearchListsBean
import com.example.shiwuyouproject.ui.fragment.my.activity.bean.MyApplicationBean

class SearchForCoursesViewModel:BaseViewModel() {
    private val loginRepository by lazy { RetrofitClient.getApiService() }
    /**
     * 搜索历史记录
     */
    val getSearchListsStatus = MutableLiveData<MutableList<GetSearchListsBean>>()
    fun getSearchLists(){
        launch(
            block = {
                val codeStatus = loginRepository.getSearchLists()
                getSearchListsStatus.value=codeStatus.result().data
            },
            error = {
            },
            cancel = {

            },
            showErrorToast = false
        )
    }

    /**
     * 搜索课程
     */
    val getGenRenStatus = MutableLiveData<MutableList<MyApplicationBean>>()
    fun getCommissionLists(keywords:String){
        launch(
            block = {
                val codeStatus = loginRepository.getPostSearch("510700",keywords)
                getGenRenStatus.value=codeStatus.result().data.data
            },
            error = {
            },
            cancel = {

            },
            showErrorToast = false
        )
    }
}